package com.jackchen.service.impl;

import java.util.List;
import java.util.Map;

import java.io.Serializable;

import com.jackchen.dao.IBaseDAO;
import com.jackchen.service.IBaseService;

public class IBaseServiceImpl implements IBaseService{
	
	private IBaseDAO iBaseDAO;
	
	public Serializable insert(Object entity){
		return iBaseDAO.save(entity);
	}
	
	public void update(Object entity){
		iBaseDAO.update(entity);
	}
	
	public void saveOrUpdate(Object entity){
		iBaseDAO.saveOrUpdate(entity);
	}
	
	public void deleteAll(List list){
		iBaseDAO.deleteAll(list);
	}
	
	public <T> void deleteById(Class<T> entityClassName,Serializable deleteId){
		iBaseDAO.deleteById(entityClassName, deleteId);
	}
	
	public List findAll(String aClassName){
		return iBaseDAO.findAll(aClassName);
	}
	
	public List findByExample(Object aObject){
		return iBaseDAO.findByExample(aObject);
	}
	
	public List findByPropertyName(String aPropertyName,Object aObject){
		return iBaseDAO.findByNamedQuery(aPropertyName, aObject);
	}
	
	public Map findByPage(String aClassName,int aPageSize,int aStartRow){
		return iBaseDAO.findByPage(aClassName, aPageSize, aStartRow);
	}

	
	public IBaseDAO getiBaseDAO() {
		return iBaseDAO;
	}


	public void setiBaseDAO(IBaseDAO iBaseDAO) {
		this.iBaseDAO = iBaseDAO;
	}

	@Override
	public List<Object> findObjBySql(String sql, Object... objects) {
		return iBaseDAO.findObjBySql(sql, objects);
	}
	
	@Override
	public List<Object> findObjByHSql(String sql, Object... objects) {
		return iBaseDAO.findObjByHSql(sql, objects);
	}


	public <E> E findById(Class<E> entityClass, Serializable id) {
		return this.iBaseDAO.findById(entityClass, id);	
	}
	
}
